/*
 * Utils.h
 *
 *  Created on: Apr 19, 2012
 *      Author: thuvh
 */
#include <iostream>
#include <vector>

#include "Symbol.h"

#ifndef UTILS_H_
#define UTILS_H_

//const enum TYPE_OF_SYMBOL = { NON_TERMINAL = 1, NON_TERMINAL_IS_HEAD = 2, TERMINAL }
enum NUM_OF_ELE {ERROR = 0, NON_TERMINAL = 1, TERMINAL_OR_HEAD_NON_TERMINAL = 2} ;
const std::size_t NUM_OF_ELE_IN_LINE = 3; //word tag chunk

std::vector<std::string> tokenize(std::string inpStr, std::string delim = " ");
/**
 * input $AB
 * input $AB[H]
 * input $AB["the"]
 */
Symbol * getSymbol(std::string inpStr, int start = 0, int end = 1);

std::vector<int> getIntVect (std::string inpStr);
int s2i (std::string inpStr);
Symbol * loadRuleFromFile (std::string filename);

std::vector<Symbol *> loadSentence (std::vector<std::string> words, std::vector<std::string> tags, std::vector<std::string> chunks);
std::vector<std::vector<Symbol *> > loadSentences (std::string filename);

std::vector<std::size_t> segment (std::vector<std::string> chunks);

void loadFile (std::string filename, Symbol * rules);

/**
 * compare between chunk in level 1 and rule
 * @param sentence - root of sentene
 * @param rule - rule need check
 * @return true or false
 */
bool isMatch (Symbol * chunk, Symbol * rule);
bool getReorderChunk (Symbol * chunk, Symbol * rule);
bool processSentence(Symbol * sentence, Symbol * rule);

#endif /* UTILS_H_ */
